import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class showServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("dsfasdfadsfasdfasdfasdfasdfa");
        List list=new ArrayList();
        List list1=new ArrayList();
//        list.add("新闻标题1");
//        list.add("新闻标题2");
//        list.add("新闻标题3");
        try {
            list=new DBHelper().query();
            list1=new DBHelper().query1();
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        request.setAttribute("titlelist",list);
        request.setAttribute("contentlist",list1);
        request.getRequestDispatcher("/show.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request,response);
    }
}
